<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let data = [
        { name: '张衡', age: 40, gender: '男', height: 175 },
        { name: '花木兰', age: 20, gender: '女', height: 165 },
        { name: '张仲景', age: 35, gender: '男', height: 170 },
        { name: '武则天', age: 30, gender: '女', height: 168 },
        { name: '孙膑', age: 38, gender: '男', height: 170 },
        { name: '张仪', age: 43, gender: '男', height: 175 },
      ]
      //创建函数，函数内带参数
      function processData(filter) {
        //先设立一个空数组
        let result = []
        //使用for of循环编列data数组
        for (let item of data) {
          //使用if判断，将函数中的参数filter代入if中，在把循环声明的变量带进参数中去
          if (filter(item)) {
            //使用push方法，向数组末尾添加一个或多个新的元素，并返回其长度
            result.push(item)
          }
        }
        //然后返回数组
        return result
      }

      //  let boys = processData(function(s){return s.gender == '男'})
      //  let girs = processData(function(s){return s.gender == '女'})
      //  let girs = processData(function(s){return s.gender == '女'  && s.height>=160})
      //  let girs = processData(function(s){return s.gender == '女'  && s.name.startwith('zhang')})

      //  let arr = [1,2,3
      //  ]
      //  arr.fiter(function(value){
      //    asdfasdfkl;asjdf
      //  })
    </script>
  </body>
</html>
